/*
7:定义两个递增有序的数组,把其合并成一个数组,并保证其仍然是有序的.
 比如,数组{1,3,5}和{2,4,6,8},合并后是{1,2,3,4,5,6,8}
提示:新数组长度是两者的和,判断每一个数是大是小,放入新数组中*/
package ZUOYE0424;

import java.util.Scanner;

public class Task7 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num[] = new int[10];
		int num1[] = new int[10];
		System.out.println("输入第一组数：");
		for (int n = 0; n < num.length; n++) {
			num[n] = in.nextInt();
		}
		System.out.println("输入第二组数：");
		for (int n1 = 0; n1 < num1.length; n1++) {
			num1[n1] = in.nextInt();
		}
		int num2[] = new int[20];
		for (int n2 = 0, x = 0, y = 0; n2 < num2.length; n2++) {
			if (num[x] < num1[y]) {
				num2[n2] = num[x];
				System.out.println(num2[n2]);
				x++;
				if (x == num.length) {
					num2[n2 + 1] = num1[9];
					System.out.println(num2[n2 + 1]);
					break;
				}
			} else if (num[x] > num1[y]) {
				num2[n2] = num1[y];
				System.out.println(num2[n2]);
				y++;
				if (y == num1.length) {
					num2[n2 + 1] = num[9];
					System.out.println(num2[n2 + 1]);
					break;
				}
			} else {
				num2[n2] = num1[y];
				System.out.println(num2[n2]);
				y++;
				if (y == num1.length) {
					num2[n2 + 1] = num[9];
					System.out.println(num2[n2 + 1]);
					break;
				}
			}
		}

	}

}
